#include<iostream>
#include<vector>
#include<string.h>
using namespace std;
int n{0}, tmp{0}, a[103];
vector<int> v;
int dp(int i);


int main()
{
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> tmp;
        v.push_back(tmp);
    }
    memset(a, 0, sizeof(a));
    cout << dp(0) << endl;


    return 0;
}


int dp(int i) // 位置很重要
{
    if (i >= n) return 0;
    if(a[i]) return a[i];  // 记忆数据！
    a[i+1] = dp(i+1);
    a[i+2] = dp(i+2);
    int money1{0}, money2{0};
    money1 = v[i] + a[i+2];
    money2 = a[i+1];
    if (money1 > money2) return money1;
    else return money2;
}